function getTime(callback) {
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.open('POST', '/Trabalho_PD/TimeWebService', true);
    var request =
            '<?xml version="1.0" encoding="utf-8"?>' +
            '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
            '<soap:Body>' +
            '<ns0:getTime xmlns:ns0="http://webservice/"/>' +
            '</soap:Body>' +
            '</soap:Envelope>';
    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState === 4) {
            if (xmlhttp.status === 200) {
                callback($.parseJSON(xmlhttp.responseXML.childNodes.item(0).textContent));
            }
        }
    };
    
    xmlhttp.onerror = function (e) {
        alert("Error contacting server!");
    };

    xmlhttp.setRequestHeader('Content-Type', 'text/xml');
    xmlhttp.send(request);
}

function setTime(date, callback) {
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.open('POST', '/Trabalho_PD/TimeWebService', true);
    var request =
            '<?xml version="1.0" encoding="utf-8"?>' +
                '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
                '<soap:Body>' +
                '<ns0:setTime xmlns:ns0="http://webservice/">' +
                    '<date>' + date + '</date>' +
                '</ns0:setTime>' +
                '</soap:Body>' +
            '</soap:Envelope>';
    
    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState === 4) {
            if (xmlhttp.status === 200) {
                callback();
            }
        }
    };
    
    xmlhttp.onerror = function (e) {
        alert("Error contacting server!");
    };
    
    xmlhttp.setRequestHeader('Content-Type', 'text/xml');
    xmlhttp.send(request);
}


